package cn.kduck.code.generate.json;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

public class AiChatRequest {
    private String model;
    private ChatMessage[] messages;
    private boolean stream;

    @JsonProperty("max_tokens")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Integer maxTokens = 8192;//deepseek默认为4096，最大8192
    private AiFunctionToolRequest[] tools;
    @JsonProperty("tool_choice")
    private String toolChoice;

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public ChatMessage[] getMessages() {
        return messages;
    }

    public void setMessages(ChatMessage[] messages) {
        this.messages = messages;
    }

    public boolean isStream() {
        return stream;
    }

    public void setStream(boolean stream) {
        this.stream = stream;
    }

    public Integer getMaxTokens() {
        return maxTokens;
    }

    public void setMaxTokens(Integer maxTokens) {
        this.maxTokens = maxTokens;
    }

    public String getToolChoice() {
        return toolChoice;
    }

    public void setToolChoice(String toolChoice) {
        this.toolChoice = toolChoice;
    }

    public AiFunctionToolRequest[] getTools() {
        return tools;
    }

    public void setTools(AiFunctionToolRequest[] tools) {
        this.tools = tools;
    }

    public static class ChatMessage{
        private String role;
        private String content;

        @JsonProperty("tool_calls")
        private AiToolCallsJson[] toolCalls;

        @JsonProperty("tool_call_id")
        @JsonInclude(JsonInclude.Include.NON_NULL)
        private String toolCallId;

        public ChatMessage() {
        }

        public ChatMessage(String role, String content) {
            this.role = role;
            this.content = content;
        }

        public String getToolCallId() {
            return toolCallId;
        }

        public void setToolCallId(String toolCallId) {
            this.toolCallId = toolCallId;
        }

        public String getRole() {
            return role;
        }

        public void setRole(String role) {
            this.role = role;
        }

        public String getContent() {
            return content;
        }

        public void setContent(String content) {
            this.content = content;
        }

        public AiToolCallsJson[] getToolCalls() {
            return toolCalls;
        }

        public void setToolCalls(AiToolCallsJson[] toolCalls) {
            this.toolCalls = toolCalls;
        }
    }

    public static class AiChatResponse {
        private long created;
        private Choices[] choices;

        public Choices[] getChoices() {
            return choices;
        }

        public void setChoices(Choices[] choices) {
            this.choices = choices;
        }

        public long getCreated() {
            return created;
        }

        public void setCreated(long created) {
            this.created = created;
        }


    }

    public static class Choices {
        private int index;
        private ChatMessage message;

        public int getIndex() {
            return index;
        }

        public void setIndex(int index) {
            this.index = index;
        }

        public ChatMessage getMessage() {
            return message;
        }

        public void setMessage(ChatMessage message) {
            this.message = message;
        }
    }
}
